package com.yunji.system.dao.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.yunji.common.base.BaseDaoImpl;
import com.yunji.common.base.response.Response;
import com.yunji.common.model.bo.EventRecordSelectBO;
import com.yunji.common.model.domain.EventRecordDO;
import com.yunji.common.model.params.EventRecordParam;
import com.yunji.common.model.vo.EventRecordVO;
import com.yunji.common.utils.bean.BeanUtils;
import com.yunji.system.dao.IEventRecordDao;
import com.yunji.system.mapper.IEventRecordMapper;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class EventRecordDaoImpl extends BaseDaoImpl<IEventRecordMapper, EventRecordDO> implements IEventRecordDao {
    @Override
    public List<EventRecordDO> search(EventRecordParam param) {
        return list(new LambdaQueryWrapper<EventRecordDO>()
                .eq(BeanUtils.isNotNull(param.getEventDataId()), EventRecordDO::getEventDataId, param.getEventDataId())
                .eq(BeanUtils.isNotNull(param.getBusinessType()), EventRecordDO::getBusinessType, param.getBusinessType())
                .orderByAsc(EventRecordDO::getOperateTime));
    }

    @Override
    public EventRecordDO select(EventRecordSelectBO bo) {
        return getOne(new LambdaQueryWrapper<EventRecordDO>()
                .eq(EventRecordDO::getEventDataId, bo.getEventDataId())
                .eq(EventRecordDO::getBusinessType, bo.getBusinessType())
                .eq(EventRecordDO::getEventStatus, bo.getEventStatus())
                .eq(EventRecordDO::getEventType, bo.getEventType()));
    }
}
